package com.test.dozer;

import org.dozer.CustomConverter;

/**
 * Created by wxy on 2017/9/13.
 */
public class EnumIntConverter implements CustomConverter{

    @Override
    public Object convert(Object dest, Object source, Class<?> destClass, Class<?> sourceClass) {
        //.out.println("-----------");
        //.out.println("S:"+sourceClass);
        //.out.println("D:"+destClass);
        if(source==null)return null;
        if(source instanceof GenderType){
            GenderType genderType = (GenderType)source;
            if(genderType == GenderType.female){
                return 0;
            }else{
                return 1;
            }
        }
        return null;
    }
}
